const express=require('express')
const router= express.Router();
const db=require('../../utils/db')
//最上面的信息查询
router.post('/getinventory', function(req, res, next) {
    let mysql = `SELECT * FROM order_information JOIN customer on order_information.order_username=customer.customer_id JOIN 
    pay_method on order_information.order_pay_way=pay_method.pay_id join user on order_information.order_user_id=user.user_id where order_information.order_id='${req.body.id} GROUP BY order_id'`
    db(mysql, null, function(err, data) {
        if (err) {
            return res.json({
                code: 500,
                msg: '查询订单信息失败，请稍后重试'
            })
        }
        res.json({
            code: 200,
            msg: '查询订单信息成功',
            data: data
        })
    })
});
router.post('/getinventoryuser', function(req, res, next) {
    let mysql = `SELECT * FROM order_information JOIN customer on order_information.order_username=customer.customer_id JOIN 
    pay_method on order_information.order_pay_way=pay_method.pay_id join user on order_information.order_user_id=user.user_id
    join menu_file on order_information.order_menu_id=menu_file.menu_id where customer_id='${req.body.customer_id}' GROUP BY order_id`
    db(mysql, null, function(err, data) {
        if (err) {
            return res.json({
                code: 500,
                msg: '查询订单信息失败，请稍后重试'
            })
        }
        res.json({
            code: 200,
            msg: '查询订单信息成功',
            data: data
        })
    })
});
module.exports = router